<%-- 
    Document   : formConsultJourVacance
    Created on : 23 juin 2013, 17:05:16
    Author     : ali
--%>
<%@page import="EDT.api.API"%>
<%@page import="java.util.Calendar"%>
<%-- 
    Document   : formAjoutJourFeriee
    Created on : 28 mars 2013, 11:13:55
    Author     : ali
--%>


<%@page import="java.util.Date"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.text.DateFormat"%>

<%@page import="java.util.ArrayList"%>
<%@page contentType="text/html" pageEncoding="ISO-8859-1"%>
<%@taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
                
        <title>Consulter les Jours de vacances </title>
            <link rel="stylesheet" href="Accueil.css" />
            <link rel="SHORTCUT ICON" href="./edt.jpg" />
            
            <style type="text/css">
		
			dl.defs{ margin: 10px 0 10px 40px; }
			dl.defs dt{ font-weight: bold; line-height: 20px; margin: 10px 0 0 0; }
			dl.defs dd{ margin: -20px 0 10px 160px; padding-bottom: 10px; border-bottom: solid 1px #eee;}

			.wrapper{ background-color: #ffffff; width: 800px; border: solid 1px #eeeeee; padding: 20px; margin: 0 auto; }
			#tabs{ margin: 20px -20px; border: none; }
			#tabs, #ui-datepicker-div, .ui-datepicker{ font-size: 85%; }
			.clear{ clear: both; }

            </style>
		
		<link rel="stylesheet" media="all" type="text/css" href="http://code.jquery.com/ui/1.10.0/themes/smoothness/jquery-ui.css" />
		<link rel="stylesheet" media="all" type="text/css" href="jquery-ui-timepicker-addon.css" />
		
		<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.0.min.js"></script>
		<script type="text/javascript" src="http://code.jquery.com/ui/1.10.0/jquery-ui.min.js"></script>
		<script type="text/javascript" src="jquery-ui-timepicker-addon.js"></script>
		<script type="text/javascript" src="jquery-ui-sliderAccess.js"></script>
		<script type="text/javascript">
			
			$(function(){
				$('#tabs').tabs();
		
				$('.example-container > pre').each(function(i){
					eval($(this).text());
				});
			});
		</script>
            
            <script language="JavaScript">
                
                 var  disabledDays;                       
                         $(document).ready(function(){ 
                             
                             disabledDays=JourF();
                         });
                
                                
               $(document).ready(function () {
    $('#rest_example_x').datetimepicker({
        dateFormat: "dd-mm-yy",
	minDate: new Date(document.getElementsByName('anneeMin')[0].value),
	maxDate: new Date(document.getElementsByName('annee')[0].value),
        showTimepicker: false,
        beforeShowDay: noWeekendsOrHolidays
    }
 
);

});


function nationalDays(date) {
	var m = date.getMonth(), d = date.getDate(), y = date.getFullYear();
	//console.log('Checking (raw): ' + m + '-' + d + '-' + y);
	for (i = 0; i < disabledDays.length; i++) {
		if($.inArray((m+1) + '-' + d + '-' + y,disabledDays) != -1 || new Date() > date) {
			//console.log('bad:  ' + (m+1) + '-' + d + '-' + y + ' / ' + disabledDays[i]);
			return [false];
		}
	}
	//console.log('good:  ' + (m+1) + '-' + d + '-' + y);
	return [true];
}
function noWeekendsOrHolidays(date) {
	//var noWeekend = jQuery.datepicker.noWeekends(date);
	//return noWeekend[0] ? nationalDays(date) : noWeekend;
        return nationalDays(date);

}

function JourF(){

    
    var resulta = document.getElementsByName('jourf')[0].value;
    
   var tab = resulta.split(",");
    

    
    return tab;
}

         </script>   
    </head>

    <body>    
        
    <section>
        
        <%
          
        String form ="";
                              
        String key = (String) session.getAttribute("key");
          
        
     
        form += "<div class='commentaire'>\n";
       
        
        form += "<input type='hidden' name='key' value='"+key+"'/>";
        
        Calendar cal1 = Calendar.getInstance();
        Calendar cal2 = Calendar.getInstance();
        Date dateCourante = new Date();
        cal1.setTime(dateCourante);
        Date dateMax = EDT.api.API.getJourMax();
        cal2.setTime(dateMax);
        DateFormat dateFormat = new SimpleDateFormat("yyyy,MM,dd");
        DateFormat dateFormatAnnee = new SimpleDateFormat("yyyy");
        
        
        form += "<input type='hidden' name='anneeMin' value='"+dateFormat.format(cal1.getTime())+"'/>";
            
        form += "<input type='hidden' name='annee' value='"+dateFormat.format(cal2.getTime())+"'/>";
       
        
        
        String jourFerie = API.getJourferie(Integer.parseInt(dateFormatAnnee.format(cal1.getTime()))
                ,Integer.parseInt(dateFormatAnnee.format(cal2.getTime())));
        
        form += "<input type='hidden' name='jourf' value='"+jourFerie+"'/>";
        /*
        form += "<div class='example-container'>";
        form += "La date : <input type='text' name='date' id='rest_example_x' value='' onclick='' />";
        form += "</div><br/>";
        */
        form += "<div id='rest_example_x'>";
        //form += "La date : <input type='text' name='date' id='' value='' onclick='' />";
        form += "</div><br/>";
               
            
        //form += "<input type='submit' value='valider'/><br/>";
        
        out.println(form);
                
%>
        
     
    <html:errors/> 

    
        
    </div>


  
</section>

    
    </body>
</html>
